package io;

import java.io.*;
import java.util.Scanner;

public class PrintWriterDemo {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(System.in);

        PrintWriter pw =
                new PrintWriter(
                        new BufferedWriter(
                                new OutputStreamWriter(
                                        new FileOutputStream("note.txt",true)
                                )
                        ),true
                );

        while (true){
            System.out.print("输入字符串:");
            String writer = scanner.nextLine();
            if (writer.equalsIgnoreCase("exit")){
                System.out.println("程序退出");
                break;
//                return;
            }else {
                pw.println(writer);
            }
        }

        pw.close();
        scanner.close();


    }
}
